package curves.sys;

import curves.Bounds;

public class SimpleBounds implements Bounds {

    double minx, miny, maxx, maxy;
    
    public SimpleBounds(double minx, double miny, double maxx, double maxy){
        this.minx = minx;
        this.miny = miny;
        this.maxx = maxx;
        this.maxy = maxy;
    }

    public double getMinX() {
        return minx;
    }

    public double getMinY() {
        return miny;
    }

    public double getMaxX() {
        return maxx;
    }

    public double getMaxY() {
        return maxy;
    }

    public boolean intersects(Bounds bounds) {
        if(bounds.getMaxX() >= getMinX() && bounds.getMaxY() >= getMinY()
                && bounds.getMinX() <= getMaxX() && bounds.getMinY() <= getMaxY()){
            return true;
        }
        if(getMaxX() >= bounds.getMinX() && getMaxY() >= bounds.getMinY()
                && getMinX() <= bounds.getMaxX() && getMinY() <= bounds.getMaxY()){
            return true;
        }
        return false;
    }

    @Override
    public String toString(){
        return "MinX: " + minx + " MinY: " + miny + " MaxX: " + maxx + " MaxY: "+maxy;
    }

}
